package Test;

public class dome3 {
    public static void main(String[] args) {
        String str="abc";
        String st="def";
        String s=" ght ";

        //getBytes()将字符串转化为字节数组
        byte [] bus=str.getBytes();
        for (int i = 0; i < bus.length; i++) {
            System.out.println(bus[i]);//输出的是字符
        }
        System.out.println("----------");

        //toCharArray()将字符串转化为字符数组
        char [] chs=str.toCharArray();
        for (int i = 0; i < chs.length; i++) {
            System.out.println(chs[i]);//输出的字符
        }
        System.out.println("----------");

        //valueOf()将任意类型转化为字符串
        String s1=String.valueOf(123);//将任意类型转化为字符串
        System.out.println(s1);
        System.out.println("----------");

        //replace()替换旧的字符
        System.out.println(str.replace(str,st));//替换旧的字符
        System.out.println("----------");

        //split()切割字符串
        String s2="abc abc abc";
        String [] arr=s2.split(" ");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        System.out.println("----------");

        //trim清除字符串前后的空格
        System.out.println("清除前："+s);
        System.out.println("清楚后："+s.trim());//清除字符串前后的空格

        //大小写转化
        String string1="abcdefghijkmlnopqrstuvwxyz";
        System.out.println(string1.toUpperCase());//转换为大写
        String string2="ABCDEFGHIJKMLNOPQRSTUVWXYZ";
        System.out.println(string2.toLowerCase());//转换为小写
    }
}